/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
export default function access(
  initialState: { currentUser?: { user: API.UserInfo }; authorization: any } | undefined,
) {
  const { currentUser, authorization = [] } = initialState ?? {};
  const role = currentUser?.user?.role || 'VISITOR';
  //   ADMIN, // 系统管理员，所有权限
  // BOSS, // 老板，可以创建数字员工，管理知识库，对话（除用户设置外的菜单）
  // VISITOR, // 对话
  // return {
  //   '/chat': ['ADMIN', 'BOSS', 'VISITOR'].includes(role) ? true : false,
  //   '/api': ['ADMIN', 'BOSS', 'VISITOR'].includes(role) ? true : false,
  //   '/knowledge': ['ADMIN', 'BOSS'].includes(role) ? true : false,
  //   '/virtual-employee': ['ADMIN', 'BOSS'].includes(role) ? true : false,
  //   '/system': ['ADMIN'].includes(role) ? true : false,
  //   '/user': ['ADMIN', 'BOSS'].includes(role) ? true : false,
  // };
  return {
    // canAdmin: true,
    '/profile/productkey': authorization?.includes('ROLE_ADMIN') ? true : true,
  };
}
